Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Added e2e for switch network #27967

Merged
merged 15 commits into from
Oct 24, 2024
Merged

test: Added e2e for switch network #27967

merged 15 commits into from
Oct 24, 2024

Conversation

hjetpoluru
Copy link
Contributor

@hjetpoluru hjetpoluru commented Oct 18, 2024

Description

This is e2e PR for switch network

Open in GitHub Codespaces

Related issues

Fixes:
https://github.com/MetaMask/MetaMask-planning/issues/2906

Manual testing steps

Run the test locally or in codespaces using the below command:
yarn
yarn build:test:webpack
ENABLE_MV3=false yarn test:e2e:single test/e2e/tests/network/switch-network.spec.ts --browser=chrome

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@hjetpoluru hjetpoluru added team-extension-platform area-qa Relating to QA work (Quality Assurance) labels Oct 18, 2024
@hjetpoluru hjetpoluru self-assigned this Oct 18, 2024
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 18, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [f043170]
Page Load Metrics (1811 ± 101 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15742348180818690
domContentLoaded15622137175613766
load157424841811211101
domInteractive17221544321
backgroundConnect10353558440
firstReactRender462881176129
getState5155224019
initialActions00000
loadScripts11321516130010751
setupStore10200415225
uiStartup175740892141566272
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@hjetpoluru hjetpoluru marked this pull request as ready for review October 19, 2024 00:00
@hjetpoluru hjetpoluru requested review from a team as code owners October 19, 2024 00:00
@metamaskbot
Copy link
Collaborator

Builds ready [185abee]
Page Load Metrics (1799 ± 87 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint29622881658485233
domContentLoaded15602277177818187
load15742288179918287
domInteractive16271585426
backgroundConnect65717136
firstReactRender471651012110
getState312621
initialActions01000
loadScripts11191830132418388
setupStore115920168
uiStartup17522445199216680
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [aa5f232]
Page Load Metrics (2158 ± 456 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint640505821111019489
domContentLoaded164149762126934448
load165350372158949456
domInteractive27140553014
backgroundConnect9105352411
firstReactRender443881299144
getState697302412
initialActions01000
loadScripts117837861601752361
setupStore1190362512
uiStartup1816551524631058508
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [2caa271]
Page Load Metrics (2005 ± 117 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint171226112012242116
domContentLoaded169825401970231111
load171026022005243117
domInteractive17160552914
backgroundConnect885322512
firstReactRender562151144120
getState498232512
initialActions01000
loadScripts122920531471217104
setupStore1189402914
uiStartup190132042275311149
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

chloeYue
chloeYue previously approved these changes Oct 22, 2024
Copy link
Contributor

@chloeYue chloeYue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, the test looks good 🔥 Just added a couple of suggestions.

I would suggest some naming changes:

  • notification.ts seems quite a vague name -> this component represents the Network Confirmations modal for switching networks, so I would name something like network-switch-modal-confirmation or similar, so it's easier to know what it refers to (see pic)

Screenshot from 2024-10-23 10-58-38

  • dialog/... I think the folder name is again quite vague -> here both components refer to the network picker and modal, so we could have some folder name more explicit

What do you think?

Copy link
Contributor Author

@hjetpoluru hjetpoluru Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @seaona for the detailed and valuable feedback.

Name Change

  • I agree with you that notification.ts is generic and a more accurate name as you suggested, will be network-switch-modal-confirmation and will make the change.
  • Since Dialog is the component, anything related to it should come under this folder. I can't think of any other options. Could you suggest some alternatives? It would be helpful.


async clickApproveButton(): Promise<void> {
console.log('Click Approve Button');
await this.driver.clickElement(this.submitButton);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to avoid race conditions:

Suggested change
await this.driver.clickElement(this.submitButton);
await this.driver.clickElementAndWaitToDisappear(
this.submitButton,
);

Copy link
Contributor Author

@hjetpoluru hjetpoluru Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually tried using clickElementAndWaitToDisappear but it was unable to click properly. Since this is a dialog and I used clickElement instead. I will try again and check locally, and I will keep you updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I have updated clickElementAndWaitToDisappear and it worked locally and pushed up the changes.

await homePage.check_expectedBalanceIsDisplayed('25');
await headerNavbar.check_currentSelectedNetwork('Localhost 8545');

// Add Aribtrum network and perform the switch network functionality
Copy link
Contributor

@seaona seaona Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Aribtrum should be Arbitrum

The test is called: Switch network - Ethereum Mainnet and Sepolia, however here we are adding Arbitrum network and switching to it too.
I would suggest either split this into 2 different tests and add more precise test naming, or change the test naming so it represents the complete test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I will change this..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seaona, I believe this test scenario is a simple one, so I have simplified the test name and provided comments. This should be sufficient. Please let me know if anything else needs to be updated


async clickCloseButton(): Promise<void> {
console.log('Click Close Button');
await this.driver.clickElement(this.closeButton);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await this.driver.clickElement(this.closeButton);
await this.driver.clickElementAndWaitToDisappear(
this.closeButton,
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this change.


async clickAddButton(): Promise<void> {
console.log('Click Add Button');
await this.driver.clickElement('[data-testid="test-add-button"]');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await this.driver.clickElement('[data-testid="test-add-button"]');
await this.driver.clickElementAndWaitToDisappear(
'[data-testid="test-add-button"]',
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this change.

@metamaskbot
Copy link
Collaborator

Builds ready [70b9cd1]
Page Load Metrics (2076 ± 93 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint33025521926535257
domContentLoaded18302531204018087
load18442557207619493
domInteractive3098522110
backgroundConnect886322512
firstReactRender592961124723
getState667292311
initialActions01000
loadScripts13261924152815775
setupStore1381352412
uiStartup205628602321232111
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

seaona
seaona previously approved these changes Oct 24, 2024
Copy link
Contributor

@seaona seaona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Co-authored-by: seaona <54408225+seaona@users.noreply.github.com>
@metamaskbot
Copy link
Collaborator

Builds ready [c08dbca]
Page Load Metrics (2183 ± 97 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint68024952101379182
domContentLoaded17852476214720297
load18072536218320197
domInteractive3311253178
backgroundConnect10166383517
firstReactRender473061317235
getState589332914
initialActions01000
loadScripts13391899160816278
setupStore1496412512
uiStartup197430902488306147
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [2318c32]
Page Load Metrics (2205 ± 176 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27636022126556267
domContentLoaded186634962163354170
load187036042205367176
domInteractive16125482211
backgroundConnect8108332813
firstReactRender562721234823
getState589272613
initialActions01000
loadScripts135328071635313150
setupStore1297342713
uiStartup208743082490463222
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Contributor

@NiranjanaBinoy NiranjanaBinoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hjetpoluru hjetpoluru added this pull request to the merge queue Oct 24, 2024
Merged via the queue into develop with commit 82eb8ff Oct 24, 2024
76 checks passed
@hjetpoluru hjetpoluru deleted the switch-network-e2e branch October 24, 2024 19:18
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2024
@metamaskbot metamaskbot added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-qa Relating to QA work (Quality Assurance) INVALID-PR-TEMPLATE PR's body doesn't match template release-12.7.0 Issue or pull request that will be included in release 12.7.0 team-extension-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants